// pages/shopInfo/shopInfo.js
// 合并不了
let $ = require('../../utils/httpUtil.js');
let _login = require('../../utils/login.js');
let _dateUtils = require('../../utils/dateUtils.js');
const WxParse = require("../../wxParse/wxParse.js");
let scrollTime = new Date().getTime();
let scrollArr = [];
Page({
    /**
     * 页面的初始数据
     */
    data: {
        canIUse: wx.canIUse('button.open-type.getUserInfo'),
        jiazailoding: 1,
        shopId: '',
        goodsSupport: 1,
        zhuoID: '',
        zhuoTitle: '',
        listview1height: 0,
        listviewheight: 0,
        shopInfo: {},
        shopSendMinprice: 0,
        shopSendPrice: 0,
        manjianed: [],
        manjiana: '',
        manjians: [],
        manjianPanduan: [],
        manjianz: [],
        manjiancheckALL: [],
        manjiancheck: '',
        manjianxuanzetype: 1,
        yuanjia: 0,
        zhekoujia: 0,
        addindex: 0,
        activityids1: '',
        activityids2: '',
        activityids3: '',
        activityids4: '',
        activityids5: '',
        actlist: [],
        taber: [{
            name: '外卖',
            id: 1
        }, {
            name: '评价',
            id: 2
        }, {
            name: '商家',
            id: 3
        }],
        hove: 1,
        showShopingCarts: 0,
        meunList: [],
        meunhover: 1,
        cate: 'm1',
        scrollTop: 0,
        contentList: [],
        activeMeun: [],
        alertShow: 0,

        checkalls: [],
        shopNum: 0,
        goodsNum: 0,
        money: 0,
        moneybian: 0,
        yuanmoney: 0,
        shopingType: 0,
        shopingenagh: 0,
        addwupin: [],
        wupinAll: {},

        specList: [{
            type: 1,
            names: '小份'
        }, {
            type: 2,
            names: '中份'
        }, {
            type: 3,
            names: '大份'
        }, {
            type: 4,
            names: '超大份'
        }],
        showtitle: '',
        showprice: 0,
        guigecheck: '',
        guigetitle: 0,
        guigeprice: 0,
        typeId: 0,
        guigeShow: 0,
        guigeList: [], //规格列表
        youhuiShow: 0,

        // shopId: 0,
        pinpaiDetailShow: 0,
        detailed: {},
        goodsPicArr: [],
        // 评论下拉上拉
        contentlist: [], // 列表显示的数据源
        pageSize: 10,
        allPages: '', // 总页数
        currentPage: 1, // 当前页数  默认是1
        starShow: [],
        pingjiaStar1: [true, false, false, false, false],
        pingjiaStar2: [true, true, false, false, false],
        pingjiaStar3: [true, true, true, false, false],
        pingjiaStar4: [true, true, true, true, false],
        pingjiaStar5: [true, true, true, true, true],
        pinglunList: [],

        goodsPriceDisall: 0, //商品总数
        goodsPriceDisyuan: 0, //非折扣价总数
        goodsmanjian: 0, //满减总数
        goodsmanjianall: 0, //满减未变总数
        goodsmoney: 0, //总钱
        act: {}, //活动

        status: 1, //叫零
        peoplenum: 0, //堂食人数弹窗
        manyPeople: '',
        tablewarePrice: 0,
        num1: 0,
        // 包装费
        shopingCartPackPrice: 0,
        moneyAll: 0,

        ////下面是我的定义的啦////
        isOut: 1, // 是否是外卖  1=外卖 2=堂食 
        ract: [], // 参与的活动列表
        isOpen: true, // 是否在营业时间内
        chooseSpecInfo: {}, //选中的规格的信息
        specGoodsTitle: '', // 规格中商品的名字
        specGoodsPic: '', // 规格中商品的图片
        isLotSpec: 0, //0不是 , 1 是
        //
        chooseGoodsList: null, //{}, //选中商品的列表
        chooseGoodsInfo: {}, //选中的商品的详情
        myTotalPrice: 0, //总价
        myYouhuiPrice: 0, //优惠总价
        packAmount: 0, //总包装费
        zheTs: 0,
        xinK: 0,
        xinKPrice: 0,
        yuract: [],
        isCom: 0,
        isman: 0,

		//统计左侧菜单栏的个数
		typeGoodsNum:{},

        // 购物车滚动区域
        shopingCartContentheight: 485,
        shopingCartContenttype: 0,

        // 12-20 滑动问题
        scrbefore: '',
        arrScroll: [] , 
		//分页
		pageNum:1,
    },
    callBackShowGoods: function() {

    },
    imageLoad: function(e) {
        //获取图片真实宽度
        var imgwidth = e.detail.width,
            imgheight = e.detail.height,
            //宽高比
            ratio = imgwidth / imgheight;
        console.log(imgwidth, imgheight)
        //计算的高度值
        var viewHeight = 750 / ratio;
        var imgheight = viewHeight
        var imgheights = this.data.imgheights
        //把每一张图片的高度记录到数组里
        imgheights.push(imgheight)
        this.setData({
            imgheights: imgheights,
        })
    },
    getUserInfo: function(e) {
        console.log(123);
        var that = this;
        _login.loginx(this, function() {
            console.log(111);
            that.setData({
                canIUse: false
            })
        });
    },
    handletouchtart: function(e) {
        console.log(123456);
        // this.bindGetUserInfo(e);
        // this.setData({
        //     canIUse: false,
        // })
    },
    handletouchend: function(e) {
        // console.log(654321);
        // this.setData({
        //     canIUse: true,
        // })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        scrollArr = [];
        wx.showLoading({
            title: '加载中...',
        })
        var _this = this;
        wx.getSetting({
            success(res) {
                if (res.authSetting['scope.userInfo']) {
                    // 已经授权，可以直接调用 getUserInfo 获取头像昵称
                    wx.getUserInfo({
                        success(res) {
                            _this.setData({
                                canIUse: false,
                            })
                        }
                    })
                }
            }
        })

        // options.scene = '1-1k71p';
        // options.scene = '7s';
        // options.scene = '1-1k731';
        // options.scene = '92f1k';
        // options.scene = '1-aiu6oyb2';

        if (options.scene) {
            var scene = options.scene;
            if (scene.includes('-')) {
                var arr = scene.split('-');
                this.data.taber[0].name = '点餐';
                this.setData({
                    shopId: arr[1],
                    goodsSupport: 2,
                    taber: this.data.taber,
                    zhuoID: arr[0],
                    isOut: 2
                })
                wx.setStorageSync('tangshi', 2);
                wx.setStorageSync('zhuoID', arr[0]);
            } else {
                this.setData({
                    shopId: options.scene,
                    goodsSupport: 1,
                    isOut: 1
                })
                wx.setStorageSync('tangshi', 1);
            }
        } else {
            this.setData({
                shopId: options.shopId,
                // shopId: '7s',
                goodsSupport: 1,
                isOut: 1
            })
            wx.setStorageSync('tangshi', 1);
        }


        this.getShopById(); //商店详情
        //this.meunL(); //左侧菜单
        this.table(); //桌台信息
        //取出缓存中的订单菜品信息


    },
	//计算左侧分类下面的商品个数
	showTypeGoodsNum: function () {
		let goodsList = this.data.chooseGoodsList;
		let typeNum = {};
		for (var ty in goodsList) {
			let yyid = goodsList[ty].goodsType;
			typeNum[yyid] = (typeNum[yyid] ? Number(typeNum[yyid]) : 0) + goodsList[ty].cnum;
		}
		console.log(typeNum);
		this.setData({
			typeGoodsNum: typeNum
		})

	},
    showOrderCache: function() {
        var order = wx.getStorageSync('orderInfo-' + this.data.shopId + '-' + this.data.isOut);
        console.log(order);
        if (order && order.goodsList) {
            var goodsIn = order.goodsList;
            if (goodsIn) {
                var cn = 0;
                //var priceNum = 0;
                //var isOut =  this.data.isOut;
                for (var goo in goodsIn) {
                    console.log(goodsIn[goo]);
                    var go = goodsIn[goo];
                    cn += go.cnum;
                    //priceNum += (isOut== 1?(goodsIn.priceOut*100):(goodsIn.priceRoom*100));
                }
                console.log(order.totalPrice)
                var actList = order.activityids.split(',');
                var ttpr = 0;
                for (var i = 0; i < actList.length; i++) {
                    if (actList[i].split('-')[0] == 1) {
                        ttpr += Number(actList[i].split('-')[1]);
                    }
                }

                this.setData({
                    chooseGoodsList: goodsIn,
                    packAmount: order.packPrice,
                    myTotalPrice: order.totalPrice,
                    shopingType: 1,
                    shopNum: cn,
                    goodsmoney: (Number(order.totalPrice + ttpr) / 100).toFixed(2),
                    shopingenagh: this.data.isOpen ? 1 : 0,
                    activityids: order.activityids
                })
            }
        }
		this.showTypeGoodsNum();
    },
    showBigImg: function(e) {
        console.log(123);
        var im = e.currentTarget.dataset.img;
        var ims = e.currentTarget.dataset.imgs;
        console.log(ims);
        if (!ims) {
            ims = [im];
        }
        wx.previewImage({
            current: im, // 当前显示图片的http链接
            urls: ims // 需要预览的图片http链接列表
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    // 获取滚动界限高度
    listViewScrollTop: function() {

        if (this.data.shopType == 2) {
            return;
        }

        let query = wx.createSelectorQuery();
        let that = this;
        let height1 = 0,
            height = 0,
            heightCount = 0,
            activeMeuns = [];
        //2.065517171223953
        //2.065517171223958
        //分类栏的高度
        height1 = 2.065517171223958 * this.data.meunList.length;
        console.log(height1);
        // query.select('.listview1').boundingClientRect(function(rect) {
        //     console.log(rect);
        //     // that.setData({
        //     //     listview1height: rect.height
        //     // })
        //     height1 = rect.height
        //     console.log(height1);
        // }).exec();
        //商品item的高度
        // query.select('.listview').boundingClientRect(function(rect) {
        // console.log(rect);
        // that.setData({
        //     listviewheight: rect.height
        // })
        // height = rect.height
        height = 85.99137878417969;
        console.log(height);
        that.data.contentList.forEach((item, index) => {
            console.log(item)
            console.log(height, height1)
            heightCount += item.children.length * height + height1;
            var map = {};
            map[heightCount] = false;
            map['id'] = item.id;
            activeMeuns.push(map)
            console.log(activeMeuns)
        })
        that.setData({
            activeMeun: activeMeuns
        })
        // }).exec();
    },
    // 左边菜单列表
    meunL: function() {
        let that = this;
        $.reqPost('xshop/getGoodsTypeList', {
            shopId: this.data.shopId,
            pageSize: 10000
        }, function(res) {
            console.log(res.returnObject.list);
            let arr = []
            if (!res.returnObject) {
                wx.hideLoading();
                wx.showToast({
                    title: '暂无数据',
                    icon: 'none',
                    duration: 1500
                })
            }
            res.returnObject.list.forEach(function(obj, index) {
                arr.push({
                    id: obj.id,
                    name: obj.title
                })
            })
            that.setData({
                meunList: arr,
                meunhover: arr[0].id,
                cate: 'm' + arr[0].id,
            })
            that.getGoodsList();
        })
    },
    // 获取商品列表
    getGoodsList: function(gtype,page) {
        console.log(gtype);
        let that = this;
		if(gtype != that.data.meunhover){
			that.setData({
				contentList:''
			})
		}else{
			return;
		}
		that.setData({
			showList: false
		});
        console.log(that.data.meunList[0].id)
        var map = {};
        map['shopId'] = this.data.shopId;
        console.log(this.data.shopType);
        //如果是超市类型的就获取第一个类型的数据
        if (this.data.shopType == 2) {
            if (gtype) {
                map['goodsTypeId'] = gtype;
            } else {
                map['goodsTypeId'] = this.data.meunList[0].id;
				
            }
			console.log(that.data.currentPage);
			// map['pageNum'] = that.data.currentPage?that.data.currentPage:1;
			map['pageNum'] = 1;
			map['pageSize'] = 10;
        }
        map['goodsSupport'] = this.data.goodsSupport;
        $.reqPost('xshop/getGoodsList',
            map,
            function(res) {
				console.log(res);
				if(res.returnObject&& res.returnObject.list){
					that.setData({
						currentPage:res.returnObject.pageNum
					})
				}
                let arr = [];
				console.log(that.data.meunList);
                that.data.meunList.forEach(function(obj, index) {
                    let arr1 = []
					if(!res.returnObject){
						return;
					}
                    res.returnObject.forEach(function(item, ind) {
						
                        if (obj.id == item.goodsTypeId) {
                            arr1.push({
                                goodsTitle: item.goodsTitle,
                                goodsDetail: item.goodsDetail,
                                id: item.id,
                                priceOut: that.trans(item.priceOut),
                                priceRoom: that.trans(item.priceRoom),
                                goodsPackAmount: that.trans(item.goodsPackAmount) ? that.trans(item.goodsPackAmount) : '0',
                                specId: 0,
                                goodsPic: item.goodsPic,
                                goodsPicArr: item.goodsPicArr,
                                goodsPriceDis: item.goodsPriceDis ? that.trans(item.goodsPriceDis) : null,
                                goodsPriceDisAdd: item.goodsPriceDisAdd,
                                goodsPriceDisNum: item.goodsPriceDisNum,
                                goodsSupport: item.goodsSupport,
                                goodsStock: item.goodsStock,
                                biz30Day: item.biz30Day,

								goodsType: item.goodsTypeId,
                                goodsTitleSimple: item.goodsTitleSimple,
                                specList: item.specList,
                                goodsStartAt: item.goodsStartAt,
                                goodsLimitBuy: item.goodsLimitBuy
                            })
                        }
                    })
                    
					// if (that.data.shopType == 2) {
					// 	console.log(page);
					// 	console.log(obj.children);
					// 	if (page && obj.children){
					// 		arr1 = arr1.concat(obj.children);
					// 	}
					// }
					arr.push({
						meun: obj.name,
						id: obj.id,
						children: arr1
					})

                })
				
					that.setData({
						contentList: arr,
					});
				
                console.log(arr)
                that.listViewScrollTop();
                that.setData({
                    jiazailoding: 0
                });
				setTimeout(() => {
					that.setData({
						showList: true
					});
				}, 250);
                wx.hideLoading();
            })
    },
    gomaploc: function(e) {
        console.log(e);
        var lat = e.currentTarget.dataset.lat * 1;
        var lng = e.currentTarget.dataset.lng * 1;
        wx.openLocation({
            latitude: lat,
            longitude: lng,
            scale: 18
        })
        // wx.navigateTo({
        // 	url: '../self/map/map?latitude=' + lat + "&longitude="+lng,
        // })
    },
    // 获取店铺信息
    getShopById: function() {
        let that = this;
        $.reqPost('xshop/getShopById', {
            id: this.data.shopId,
            wxUserId: wx.getStorageSync('uid'),
            latitude: wx.getStorageSync('location').lat,
            longitude: wx.getStorageSync('location').lng,
            actType: this.data.isOut
        }, function(res) {
            console.log(res);
            wx.hideLoading();
            let meng = "",
                actlist = [],
                arrtang = [];
            var ract = [];
            //处理不自营业时间内的逻辑
            if (that.data.isOut == 1) {

                var open = res.returnObject.openHours;
                console.log(open);
                let tiflag;
                var tims = open.split(",");
                for (var i = 0; i < tims.length; i++) {
                    tiflag = _dateUtils.timeRange(tims[i].split("-")[0], tims[i].split("-")[1]);
                    if (tiflag) {
                        break;
                    }
                }
                console.log(tiflag);
                if (res.returnObject.shopStatus == 3 || res.returnObject.shopStatus == 2) {
                    tiflag = false;
                }
                that.setData({
                    isOpen: tiflag
                })
            }
            that.showOrderCache();
            wx.setStorageSync('shopType', res.returnObject.shopType);
            that.setData({
                shopType: res.returnObject.shopType
            })
            that.meunL();
            //处理营业时间结束
            if (res.returnObject.atList) {
                res.returnObject.atList.forEach(function(obj, index) {
                    let act = {};

                    ract.push(obj.activityType);
                    if (that.data.goodsSupport == 1) {
                        if (obj.activityType == 2) {
                            meng = obj.content
                        };
                    } else {
                        if (obj.activityType == 4) {
                            meng = obj.content
                        }
                    }
                    switch (obj.activityType) {
                        case 1:
                            act.type = 1
                            act.icon = '../../img/order/new.png';
                            act.title = '本店新用户下单立减';
                            act.content = that.trans(obj.content) + '元'
                            that.setData({
                                xinK: obj.content,
                            })
                            break;
                        case 2:
                            act.type = 2
                            act.icon = '../../img/order/minus.png';
                            act.title = '满减活动';
                            act.content = that.manjian(obj.content)
                            break;
                        case 3:
                            act.type = 3
                            act.icon = '../../img/order/discount.png';
                            act.title = '单品折扣';
                            act.content = that.trans(obj.content)
                            break;
                        case 4:
                            act.type = 4
                            act.icon = '../../img/order/minus.png';
                            act.title = '满减活动';
                            act.content = that.manjian(obj.content)
                            break;
                        case 5:
                            act.type = 5
                            act.icon = '../../img/order/discount.png';
                            act.title = '堂食折扣';
                            act.content = (obj.content / 10).toFixed(1);
                            that.setData({
                                zheTs: obj.content,
                                manjiancheck: '堂食折扣 ' + (obj.content / 10).toFixed(1) + ' 折'
                            })
                            break;
                    }
                    actlist.push(act);
                })
                let act = {};
                that.data.actlist.forEach(function(obj, index) {
                    if (obj.type == 4 || obj.type == 5) {
                        arrtang.push(obj)
                    }
                    act['k' + obj.type] = obj.content;
                });
                that.setData({
                    act: act,
                    ract: ract,
                })

            }
            console.log(meng)
            that.setData({
                shopInfo: res.returnObject,
                shopSendMinprice: that.tranman(res.returnObject.shopSendMinprice ? res.returnObject.shopSendMinprice : '0') + '元起送',
                shopSendPrice: that.trans(res.returnObject.shopSendPrice),
                manjianed: meng ? meng.split(',') : '',
                manjians: meng ? that.manjian(meng) : '',
                manjianPanduan: meng ? that.manjianPd(meng, 1) : '',
                manjianz: meng ? that.manjianPd(meng, 2) : '',
                actlist: actlist,
                actList1: arrtang
            });
            console.log(that.data.manjians)
            if (res.returnObject.avgStar < 1) {
                that.setData({
                    starShow: [false, false, false, false, false]
                });
            } else if (res.returnObject.avgStar < 2) {
                that.setData({
                    starShow: [true, false, false, false, false]
                });
            } else if (res.returnObject.avgStar < 3) {
                that.setData({
                    starShow: [true, true, false, false, false]
                });
            } else if (res.returnObject.avgStar < 4) {
                that.setData({
                    starShow: [true, true, true, false, false]
                });
            } else if (res.returnObject.avgStar < 5) {
                that.setData({
                    starShow: [true, true, true, true, false]
                });
            } else {
                that.setData({
                    starShow: [true, true, true, true, true]
                });
            }

            if (!that.data.isOpen) {
                wx.showToast({
                    title: '店铺休息中...',
                    icon: 'none',
                    duration: 1000 * 60 * 60 * 24
                })
                that.setData({
                    manjiancheck: '店铺休息中...',
                    shopSendMinprice: '休息中...',
                    shopingenagh: 0,
                })
            }
            // 设置title
            wx.setNavigationBarTitle({
                title: res.returnObject.shopTitle,
            });
        })
    },
    // 评论列表
    getShopsCommentList: function() {
        let that = this;
        $.reqPost('xshop/getShopsCommentList', {
            shopId: that.data.shopId,
            pageNum: that.data.currentPage,
            pageSize: that.data.pageSize
        }, function(res) {
            wx.hideNavigationBarLoading()
            console.log(res);
            if (res.resultCode == 1000) {
                if (!res.returnObject) {
                    return;
                };
                let meng = [];
                // let arr = .commentPic.split(',')
                res.returnObject.list.forEach(function(obj, index) {
                    if (obj) {
                        let arr = obj.commentPic.split(',');
                        obj.commentPic = arr
                    }
                    meng.push(obj)
                })

                if (that.data.currentPage == 1) {
                    that.setData({
                        allPages: res.returnObject.pages,
                        pinglunList: meng
                    })
                } else {
                    var tempArray = that.data.pinglunList;
                    tempArray = tempArray.concat(meng);
                    that.setData({
                        allPages: res.returnObject.pages,
                        pinglunList: tempArray
                    })
                }
                console.log(that.data.pinglunList);
            }
        })
    },
    // 桌台信息
    table: function(a) {
        if (!this.data.zhuoID) {
            return;
        }
        let that = this;
        $.reqPost('table/getTablesById', {
            id: this.data.zhuoID
        }, function(res) {
            if (res.resultCode == 1000) {
                wx.setStorageSync('zhuoTitle', res.returnObject.title);
                that.setData({
                    zhuoTitle: res.returnObject.title
                })
            }
        })
    },
    // 跳转订单页面
    jumpOrder: function() {
        wx.switchTab({
            url: '/pages/order/orderList/orderList', //注意switchTab只能跳转到带有tab的页面，不能跳转到不带tab的页面
            success: function(e) { //跳转成功后刷新页面
                var page = getCurrentPages().pop();
                if (page == undefined || page == null) return;
                page.onLoad();
            }
        })
    },
    // 呼叫服务
    hujiao: function(a) {

        console.log(a.currentTarget.dataset.status);
        let that = this;
        if (a.currentTarget.dataset.status == 1) {
            $.reqPost('xshop/addTableServer', {
                shopId: that.data.shopId,
                title: that.data.zhuoTitle
            }, function(res) {
                that.setData({
                    status: 0
                });
                wx.showToast({
                    title: '已经呼叫店家服务',
                    icon: 'none'
                })
            });
            setTimeout(function() {
                that.setData({
                    status: 1
                })
            }, 30000);
        } else {
            wx.showToast({
                title: '请等待30秒再呼叫',
                icon: 'none'
            })
        }
    },
    // 输入就餐人数
    bindReplaceInput: function(e) {

        this.setData({
            manyPeople: e.detail.value
        })
    },
    // 确认就餐人数
    okpeopleNum: function() {
        if (this.data.manyPeople) {
            wx.setStorageSync('people', parseInt(this.data.manyPeople) + '-' + parseInt(this.data.manyPeople) * this.data.tablewarePrice);
            wx.navigateTo({
                url: '../order/payOrder/payOrder?shopId=' + this.data.shopId,
            })
        } else {
            wx.showToast({
                title: '请输入人数',
                icon: 'none'
            })
        }
    },
    // 评论下拉刷新
    refresh: function() {
        var that = this;
        wx.showLoading({
            title: '正在刷新',
        })

        setTimeout(function() {
            wx.hideLoading();
            that.setData({
                currentPage: that.data.currentPage,
            })
            that.getShopsCommentList();
        }, 300);
    },
	loadMoreGoods:function(){
		if(this.data.shopType == 1){
			return;
		}
		var that = this;
		// 当前页是最后一页
		if (that.data.currentPage == that.data.allPages) {
			wx.showLoading({
				title: '已经到底',
			})
			setTimeout(function () {
				wx.hideLoading();
			}, 300)
			return;
		} else {
			wx.showLoading({
				title: '正在加载...',
			})
			setTimeout(function () {
				wx.hideLoading();
				
				var tempCurrentPage = that.data.currentPage;
				console.log(tempCurrentPage);
				tempCurrentPage = tempCurrentPage + 1;
				that.setData({
					currentPage: tempCurrentPage,
				})
				that.getGoodsList(that.data.meunhover,true);
			}, 300)
		}
	},
    // 评论上拉加载更多
    loadMore: function() {
        var that = this;
        // 当前页是最后一页
        if (that.data.currentPage == that.data.allPages) {
            wx.showLoading({
                title: '已经到底',
            })
            setTimeout(function() {
                wx.hideLoading();
            }, 300)
            return;
        } else {
            wx.showLoading({
                title: '正在加载...',
            })
            setTimeout(function() {
                wx.hideLoading();
                var tempCurrentPage = that.data.currentPage;
                tempCurrentPage = tempCurrentPage + 1;
                that.setData({
                    currentPage: tempCurrentPage,
                })
                that.getShopsCommentList();
            }, 300)
        }
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    // onPullDownRefresh: function() {
    //   let that = this;
    //   wx.stopPullDownRefresh();
    //   wx.showNavigationBarLoading()
    //   this.setData({
    //     pageNum: 1
    //   })
    //   setTimeout(function() {
    //     wx.hideNavigationBarLoading()
    //     that.meunL();
    //     that.getShopById();
    //     that.table();
    //   }, 500)
    // },

    /**
     * 页面上拉触底事件的处理函数
     */
    // onReachBottom: function() {},

    // 切换tabers
    tabers: function(a) {
        let that = this
        this.setData({
            hove: a.currentTarget.dataset.id
        })
        if (this.data.hove == 2) {
            wx.showNavigationBarLoading()
            setTimeout(function() {
                that.getShopsCommentList();
            }, 200)
        }
    },

    // 更多优惠
    more: function() {
        this.setData({
            youhuiShow: 1,
            alertShow: 1
        })
    },
    // 左边菜单
    meun: function(a) {
        console.log(a);
        if (this.data.shopType == 2) {
            this.getGoodsList(a.currentTarget.dataset.id);
			
            this.setData({
                meunhover: a.currentTarget.dataset.id,
            })
            return;
        }
        this.setData({
            meunhover: a.currentTarget.dataset.id,
            cate: 'm' + a.currentTarget.dataset.id,
        })
        console.log(this.data.meunhover);
        console.log(this.data.meunList);
    },
    // 右边菜单滚动
    scroll: function(e) {

        //如果是超市,不联动
        if (this.data.shopType == 2) {
            return;
        }
        // let now = new Date().getTime()
        // if (now - scrollTime < 200) {
        //     console.log(now + '--------------------');
        //     //return
        // };
        // scrollTime = now;
        // 12-20 修改滑动start
        let that = this;
        let meunhovers = '';
        for (var i = 0; i < this.data.activeMeun.length; i++) {
            // console.log(e.detail.scrollTop + '==' + that.data.activeMeun[i]);
            var llo = that.data.activeMeun[i];
            // console.log(llo);
            for (var key in llo) {
                if (key != 'id') {
                    // console.log(key);

                    if (Number(key) >= Number(e.detail.scrollTop)) {
                        console.log('就是这个菜单');
                        // console.log(llo.id);
                        var isfla = llo[key];
                        var mid = llo.id;
                        // console.log(mid);
                        if (isfla && that.data.meunhover == mid) {
                            return;
                        } else {
                            that.data.activeMeun[i][key] = true;
                            that.setData({
                                activeMeun: that.data.activeMeun,
                                meunhover: mid
                            })
                            return;
                        }
                    } else {
                        var isfla = llo[key];
                        // console.log(isfla);
                        if (isfla) {
                            that.data.activeMeun[i][key] = false;
                            that.setData({
                                activeMeun: that.data.activeMeun
                            })
                        }
                    }


                }

            }
        }
        //return;
        // if ((e.detail.scrollTop + '').split('.')[0] == ((that.data.activeMeun[i] - 1) + '').split('.')[0]) {
        //     // if (e.detail.scrollTop == (that.data.activeMeun[i] -1)) {
        //     console.log(e.detail.scrollTop);
        //     console.log(that.data.meunList);
        //     console.log(that.data.activeMeun[i]);
        //     console.log('我是scroll');
        //     meunhovers = that.data.meunList[i].id;
        //     // that.setData({
        //     //     meunhover: that.data.meunList[i].id
        //     // })
        //     //break;
        // }
        // // }
        // return;
        // console.log(this.data.scrbefore, this.data.meunhover)
        // if (!this.data.scrbefore || this.data.scrbefore != meunhovers) {
        //     scrollArr.push(meunhovers);
        //     console.log(scrollArr);
        //     if (scrollArr.length) {
        //         console.log(scrollArr[scrollArr.length - 1])
        //         this.setData({
        //             scrbefore: scrollArr[scrollArr.length - 1],
        //             meunhover: scrollArr[scrollArr.length - 1]
        //         })
        //     }
        // }
        // 12-20 修改滑动end
        // console.log(112233445566);
        //    this.setData({
        // 	   canIUse:false
        //    })
    },
    // 监听页面滚动
    onPageScroll: function(a) {
        console.log(a);
    },
    //选中规格
    chooseSpec: function(e) {
        console.log(e);

        var specInfo = e.currentTarget.dataset;
        console.log(specInfo);
        var spec = e.currentTarget.dataset.spec;
        console.log(spec);
        specInfo.showPrice = (specInfo.price / 100).toFixed(2);
        specInfo.packAmount = spec.goodsPackAmount;
        this.setData({
            chooseSpecInfo: specInfo,
            guigecheck: specInfo.id
        })
    },
    //确定高规格
    guigeok: function(e) {
        var spec = e.currentTarget.dataset;
        console.log(e.currentTarget.dataset);
        var goodsInfo = spec.goodsinfo; //商品详情
        this.setData({
            guigeShow: 0,
        })
        if (goodsInfo.id.indexOf('_') < 0) {
            goodsInfo.goodsTitle += '(' + spec.title + ')';
            goodsInfo.id += '_' + spec.id;
        }
        goodsInfo.specId = spec.id;
        console.log(spec.datas.packAmount);
        console.log(spec);

        if (this.data.isOut == 1) {
            goodsInfo.priceOut = (spec.price / 100).toFixed(2);
            goodsInfo.goodsPackAmount = spec.datas.packAmount ? (spec.datas.packAmount / 100).toFixed(2) : 0;
        } else {
            goodsInfo.priceRoom = (spec.price / 100).toFixed(2);
            goodsInfo.goodsPackAmount = 0;
        }
        console.log(goodsInfo);
        //计算规格清单
        this.setData({
            chooseGoodsInfo: goodsInfo
        })
        this.addQingdan();
    },
    //加入清单
    addQingdan: function(a) {
        console.log(a);
        //开始封装清单数据
        var goods;
        if (a) {
            goods = a.currentTarget.dataset.all;
        } else {
            goods = this.data.chooseGoodsInfo;
        }
        var num = 0;
        console.log(goods);
        //debugger;
        var q = this.data.chooseGoodsList;
        q = q ? q : {};
        console.log(q);
        var goinfo = q[goods.id];
        console.log(goinfo);
        if (goinfo) {
            num = 1;
            goods = goinfo;
        }
        var qing = {};
        //判断起售数量
        var at = goods.goodsStartAt;
        // 判断限购数量
        var limit = goods.goodsLimitBuy;
        //如果多规格商品则不判断限购
        qing = goods;
        console.log(qing);
        //单规格
        if (goods.specList.length <= 1) {

            //如果是单品折扣的要先计算单品折扣的数量
            // if (this.data.ract.indexOf(3) > 0) {
            // 	if (qing.goodsPriceDisNum != 0 && qing.goodsPriceDisNum > qing.cnum){
            // 		wx.showToast({
            // 			title: '折扣单品限购' + qing.goodsPriceDisNum + '件',
            // 			icon: 'none',
            // 			duration: 2000
            // 		});
            // 		return;
            // 	}
            // }
            //处理每单限购

            if (limit != 0 && qing.cnum >= limit) {
                wx.showToast({
                    title: '每单限购' + limit + '件',
                    icon: 'none',
                    duration: 2000
                });
                qing.cnum--;
                //return;
            }
            //如果起售<限购 ,  就用起售,  如果起售大于限购  就用限购
            if (limit == 0 || limit > at) {
                qing.cnum = (num == 0 ? (at > 0 ? at : 1) : Number(goinfo.cnum ? goinfo.cnum : 0) + 1); //数量
            } else {
                qing.cnum = (num == 0 ? (limit > 0 ? limit : 1) : Number(goinfo.cnum ? goinfo.cnum : 0) + 1); //数量
            }
        } else {
            //多规格的话单品无法参与折扣活动
            qing.cnum = qing.cnum ? qing.cnum + 1 : 1;
        }

        console.log(qing);
        q[goods.id] = qing;

        // 新添加 滑动
        this.setData({
            chooseGoodsList: q,
            shopingCartContenttype: Object.keys(q).length
        })
        console.log(this.data.chooseGoodsList);
        //开始计算优惠信息
        this.youhui();
    },
    //计算活动,拼装成字符串形式
    ractCount: function(e, t) {
        console.log(e);
        console.log(t);
        //debugger
        var dat = {};
        if (e == 0) {
            return;
        }
        if (t == 3) {
            this.setData({
                activityids: '',
                xinKPrice: 0,
            })
        }
        //debugger
        var act = [];
        if (this.data.isCom == 0) {
            var aa = this.data.activityids;
            if (aa) {
                var actl = aa.includes(',') ? aa.split(',') : [aa];
                if (t == 1 || t == 2) {
                    for (var i = 0; i < actl.length; i++) {
                        var ac = actl[i].split('-');
                        if (ac[0] != 3) {
                            if (this.data.isman != 0) {
                                dat['k_' + ac[0]] = ac[1];
                            }
                        }
                    }
                }
            }
            this.setData({
                isCom: 1
            })
        } else {
            var aa = this.data.activityids;
            if (aa) {
                var actl = aa.includes(',') ? aa.split(',') : [aa];
                for (var i = 0; i < actl.length; i++) {
                    var ac = actl[i].split('-');
                    if (ac[0] == 3) {
                        dat = {};
                    } else {
                        dat['k_' + ac[0]] = ac[1];
                    }
                }
            }
        }

        dat['k_' + t] = e;
        for (var key in dat) {
            var val = dat[key];
            var keys = key.split('_')[1];
            act.push(keys + '-' + val);
        }
        this.setData({
            activityids: act.join(',')
        })
        console.log(this.data.activityids);
    },
    /**
     * 计算优惠
     */
    youhui: function(e) {
        console.log(this.data);
        var toprice = 0; //优惠后总价
        var huipirce = 0; //总优惠价
        var toNum = 0; //商品数量
        var packAmount = 0; //总包装费

        var huip; //满减返回的数据
        var goodsList = this.data.chooseGoodsList;
        var shopInfo = this.data.shopInfo; //店铺信息
        var eGoods = this.data.chooseGoodsInfo; //当前选择的商品
        // myTotalPrice
        //判断店铺开启了什么活动
        var ract = this.data.ract;

        //先判断是外卖还是堂食
        if (this.data.isOut == 1) {
            //外卖
            var isZheGoods = 0;
            //判断是否有折扣活动
            if (ract.includes(3)) {

                //参与折扣活动
                for (var key in goodsList) {
                    var total2 = 0;
                    var pack2 = 0;
                    //console.log("属性：" + key + ",值：" + goodsList[key]);
                    //判断商品是否有折扣价,并且规格只有一个
                    var goods = goodsList[key];
                    console.log(goods);

                    var dis = goods.goodsPriceDisNum; //限购  0不限购
                    if (dis != null && dis >= 0) {
                        if (goods.specList.length <= 1) {
                            isZheGoods = 1; // 是有折扣商品
                            //判断折扣限购
                            if (goods.cnum > dis && dis > 0) {

                                total2 = dis * (Number(goods.goodsPriceDis) * 100) + (goods.cnum - dis) * (Number(goods.priceOut) * 100);
                                toprice += goods.cnum * (Number(goods.priceOut) * 100);
                                huipirce += goods.cnum * (Number(goods.priceOut) * 100) - total2;
                            } else {
                                total2 = goods.cnum * (Number(goods.goodsPriceDis) * 100);
                                toprice += goods.cnum * (Number(goods.priceOut) * 100);
                                huipirce += goods.cnum * (Number(goods.priceOut) * 100) - total2;
                            }
                        } else {

                            //多规格的商品不参加折扣活动
                            toprice += (goods.cnum) * (Number(goods.priceOut) * 100);
                        }

                    } else {
                        //没有折扣信息的商品不参加折扣活动
                        toprice += (goods.cnum) * (Number(goods.priceOut) * 100);
                    }

                    //debugger
                    toNum += goods.cnum;
                    pack2 = goods.cnum * (goods.goodsPackAmount ? goods.goodsPackAmount * 100 : 0);
                    packAmount += pack2;
                    toprice += pack2; //包装费
                }
                //debugger
                //所选择的商品中没有一个是折扣商品,则去参加满减活动
                if (isZheGoods == 0) {
                    this.setData({
                        activityids: ''
                    })
                    toNum = 0;
                    packAmount = 0;
                    pack2 = 0;
                    //toprice =0;
                    //没有开启折扣活动,所有商品按照原价计算
                    if (ract.includes(1)) {
                        //新客立减
                        ///判断当前用户是否是新客
                        if (shopInfo.isNewUser == 'y') {
                            //是新客
                            this.ractCount(this.data.xinK, 1);
                            this.setData({
                                xinKPrice: this.data.xinK
                            })
                        }
                    }
                    if (ract.includes(2) > 0) {
                        //满减活动
                        //计算满减
                        huip = this.fullReduction(); //计算满减,并返回优惠价格
                    }
                    for (var key in goodsList) { //遍历已经选择的菜品
                        var goods = goodsList[key];
                        console.log(goods);
                        toNum += goods.cnum;
                        //计算包装费
                        pack2 = this.countPackAmount(goods);
                        console.log(pack2);
                        //pack2 = goods.cnum * (goods.goodsPackAmount ? goods.goodsPackAmount * 100 : 0);
                        packAmount += pack2;
                        //toprice += pack2; //包装费
                    }
                }
            } else {
                //  debugger
                //没有开启折扣活动,所有商品按照原价计算
                if (ract.includes(1)) {
                    //新客立减
                    ///判断当前用户是否是新客
                    if (shopInfo.isNewUser == 'y') {
                        //是新客
                        this.ractCount(this.data.xinK, 1);
                        this.setData({
                            xinKPrice: this.data.xinK
                        })
                    }
                }
                if (ract.includes(2)) {
                    //满减活动
                    //计算满减
                    huip = this.fullReduction(); //计算满减,并返回优惠价格
                }
                for (var key in goodsList) { //遍历已经选择的菜品
                    var goods = goodsList[key];
                    console.log(goods);
                    toprice += (goods.cnum) * (Number(goods.priceOut) * 100);
                    toNum += goods.cnum;
                    pack2 = goods.cnum * (goods.goodsPackAmount ? goods.goodsPackAmount * 100 : 0);
                    packAmount += pack2;
                    toprice += pack2; //包装费
                }
            }

            if (huip) {
                toprice = huip.toprice;
                huipirce = huip.huipirce;

                this.ractCount(huipirce, 2);
            } else {
                var showInfo = '折扣已减 ' + (huipirce / 100).toFixed(2) + ' 元';
                this.setData({
                    manjiancheck: showInfo,
                })
                this.ractCount(huipirce, 3);
                //huipirce = 0;
            }
            //回显总价价格和优惠价格
            console.log(toprice);
            console.log(huipirce);
            //判断总价是否超过起送费 , 超过了就可以去结算了
            var shopingenagh = 0;
            var shopSendMinprice = 0;
            var tp = 0;
            if (toprice > 0) {
                tp = toprice;
            }

            // debugger
            if (shopInfo.shopSendMinprice <= tp) {
                shopingenagh = this.data.isOpen ? 1 : 0;
            } else {
                shopSendMinprice = shopInfo.shopSendMinprice - toprice;
            }

            var shopingType = 1;
            if (toNum == 0) {
                shopingType = 0;
            }
            var pp = ((toprice - huipirce) / 100).toFixed(2); //地球旁边显示的总价
            var xinkp = huipirce + (this.data.xinK ? this.data.xinK : 0);
            this.setData({
                goodsmoney: toprice <= 0 ? '0.00' : pp,
                shopNum: toNum, //清单地球数量
                shopingType: shopingType, //控制是否显示地球
                myTotalPrice: toprice - huipirce - this.data.xinKPrice,
                myYouhuiPrice: huipirce,
                shopingenagh: shopingenagh,
                shopSendMinprice: '还差' + (shopSendMinprice / 100) + '元起送',
                packAmount: packAmount, //总包装费
                shopingCartPackPrice: (packAmount / 100).toFixed(2),
            })
            console.log(this.data.myTotalPrice);
        } else {
            //堂食
            //优先选择折扣活动
            var huodongt = 5;
            if (ract.includes(5)) {
                huodongt = 5;
                console.log(ract);
                console.log(this.data.zheTs);
                //不用计算满减 ,总价打折
                //原价计算
                for (var key in goodsList) { //遍历已经选择的菜品
                    var goods = goodsList[key];
                    console.log(goods);
                    toprice += (goods.cnum) * (Number(goods.priceRoom) * 100);
                    toNum += goods.cnum;
                    huipirce += (goods.cnum) * (Number(goods.priceRoom) * 100) - ((goods.cnum) * (Number(goods.priceRoom) * (this.data.zheTs)))
                }

                var showInfo = '堂食折扣 ' + (huipirce / 100).toFixed(2) + ' 元';
                this.setData({
                    manjiancheck: showInfo
                })
            } else if (ract.includes(4)) {
                huodongt = 4;
                //满减活动
                for (var key in goodsList) { //遍历已经选择的菜品
                    var goods = goodsList[key];
                    toNum += goods.cnum;
                }
                huip = this.fullReduction(); //计算满减,并返回优惠价格
            } else {
                huodongt = 0;
                //原价计算
                for (var key in goodsList) { //遍历已经选择的菜品
                    var goods = goodsList[key];
                    console.log(goods);
                    toprice += (goods.cnum) * (Number(goods.priceRoom) * 100);
                    toNum += goods.cnum;
                }
            }
            console.log(huip);
            if (huip) {
                toprice = huip.toprice;
                huipirce = huip.huipirce;
            }
            //回显总价价格和优惠价格
            console.log(toprice);
            console.log(huipirce);
            //判断总价是否超过起送费 , 超过了就可以去结算了
            var shopingenagh = 0;
            var shopSendMinprice = 0;
            var tp = 0;
            if (toprice > 0) {
                tp = toprice;
            }
            if (0 <= tp) {
                shopingenagh = this.data.isOpen ? 1 : 0;
            } else {
                shopSendMinprice = shopInfo.shopSendMinprice - toprice;
            }




            var shopingType = 1;
            if (toNum == 0) {
                shopingType = 0;
            }
            var pp = ((toprice - huipirce) / 100).toFixed(2); //地球旁边显示的总价
            var myp = 0;
            if (huodongt == 5) {
                myp = Number(((toprice * this.data.zheTs) / 100).toFixed(0));
                //huipirce = toprice - myp;
                this.ractCount(toprice - myp, 5);
            } else if (huodongt == 4) {
                myp = toprice;
                this.ractCount(huipirce, 4);
            } else {
                myp = toprice;
            }
            this.setData({
                goodsmoney: toprice == 0 ? 0 : pp,
                shopNum: toNum, //清单地球数量
                shopingType: shopingType, //控制是否显示地球
                myTotalPrice: huodongt == 5 ? myp : myp - huipirce,
                myYouhuiPrice: huipirce,
                shopingenagh: shopingenagh
            })
        }
		this.showTypeGoodsNum();
    },
    //计算包装费
    countPackAmount: function(e) {
        console.log(e);
        var goods = e;
        //判断当前商品是不是多规格的, 多规格的取出对应规格的商品包装费

        var pack = goods.cnum * (goods.goodsPackAmount ? goods.goodsPackAmount * 100 : 0);
        return pack;
    },
    //计算满减
    fullReduction: function(e) {
        var toprice = 0; //总价
        var showInfo = ""; //打印活动信息 
        var huip = 0; //总优惠价格
        console.log(e);
        var atList = this.data.shopInfo.atList;
        var goodsList = this.data.chooseGoodsList;
        //判断是堂食的满减 还是 外卖的满减
        //获取 外卖或者堂食的 满减活动
        var atInfo = "";

        for (var i = 0; i < atList.length; i++) {
            if (this.data.isOut == 1 && atList[i].activityType == 2) {
                //外卖
                atInfo = atList[i].content;
                break;
            } else if (this.data.isOut == 2 && atList[i].activityType == 4) {
                //堂食
                atInfo = atList[i].content;
                break;
            }
        }
        //堂食和外卖的满减算法一致
        var atInfoList = atInfo.split(',');
        console.log(atInfoList);
        //判断活动内容是否为空
        var mapArr = []; //暂存活动对象,遍历
        if (atInfo) {
            //处理活动内容
            for (var i = 0; i < atInfoList.length; i++) {
                var ati = atInfoList[i];
                mapArr.push(this.actInfo(ati, ati.split('-')[0]));
            }
            console.log(mapArr);
            //冒泡排序法 b-a 倒序 ,a-b 正序
            mapArr.sort(function(a, b) {
                return b.val - a.val;
            });
            console.log(mapArr);
            //计算满减
            for (var key in goodsList) {
                var goods = goodsList[key];

                toprice += (goods.cnum) * (Number(this.data.isOut == 1 ? goods.priceOut : goods.priceRoom) * 100 + (this.data.isOut == 1 ? Number(goods.goodsPackAmount) * 100 : 0)); //计算所有菜品的总价和包装费
            }
            //开始遍历活动范围,并打印对应的活动信息
            for (var i = 0; i < mapArr.length; i++) {
                var pri = Number(mapArr[i].val);
                console.log(mapArr[i].title);
                //判断价格
                if ((pri) <= toprice) {
                    if (i == 0) {
                        showInfo = '已减' + (Number((mapArr[i].title).split('-')[1]) / 100) + '元 ';
                    } else {
                        showInfo = '已减' + (Number((mapArr[i].title).split('-')[1]) / 100) + '元，再买' + ((Number(mapArr[i - 1].val) - toprice) / 100) + '元减' + (Number((mapArr[i - 1].title).split('-')[1]) / 100);
                    }
                    huip = Number((mapArr[i].title).split('-')[1]);
                    break;
                }
            }
            console.log(showInfo);
            var actt = [];

            if (!showInfo) {
                var act = this.data.activityids;
                if (act) {
                    if (act.includes(',')) {
                        var ac = act.split(',');
                        for (var i = 0; i < ac.length; i++) {
                            if (ac[i].includes('-')) {
                                var a = ac[i].split('-');
                                if (a[0] != 2) {
                                    actt.push(ac[i]);
                                }
                            }
                        }
                    } else {
                        actt.push(act);
                    }
                }
                if (actt) {
                    this.setData({
                        activityids: actt.join(','),
                    })
                }
            } else {

            }
            //如果一个活动都没有参加 , 则返回总价
            this.setData({
                manjiancheck: showInfo,

            })

        }
        console.log(mapArr);
        //返回 满减的总价 和 总优惠价格
        var m = {};
        m.toprice = toprice;
        m.huipirce = huip;
        return m;
    },
    //暂存活动对象
    actInfo: function(title, val) {
        var map = {};
        map.title = title;
        map.val = val;
        return map;
    },
    // 添加商品
    add: function(a) {
        console.log(a);

        var _this = this;
        var goodsInfo = a.currentTarget.dataset.all; // 商品详情
        var actList = a.currentTarget.dataset.datas; //规格列表
        //判断商品库存数量
        var stock = goodsInfo.goodsStock;
        console.log(stock);
        console.log(goodsInfo);
        console.log(this.data.chooseGoodsInfo);
        var ginf;
        if (this.data.chooseGoodsList && Object.keys(this.data.chooseGoodsList).length > 0) {
            ginf = this.data.chooseGoodsList[goodsInfo.id];
        }
        var snum = 1;
        if (ginf) {
            snum = ginf.cnum + 1;
        }
        if (stock <= 0) {
            wx.showToast({
                title: '该商品已售罄',
                icon: 'none',
                duration: 1000,
            })
            return;
        } else if (snum > stock) {
            wx.showToast({
                title: '已超出剩余库存',
                icon: 'none',
                duration: 1000,
            })
            return;
        }
        _this.setData({
            chooseGoodsInfo: goodsInfo,
            activityids: ''
        })
        //判断是否有多规格, 有多规格打开选择规格界面
        if (actList.length > 1) {
            if (goodsInfo.id.indexOf('_') >= 0) {
                //说明是多规格然后再清单里面点击的添加事件
                //直接调往添加清单数据,无需再次选择规格页面
                this.addQingdan(a);
                return;
            }
            var specInfo = {};
            //默认显示第一种规格
            // chooseSpecInfo: specInfo,

            specInfo.id = actList[0].id;
            specInfo.price = _this.data.isOut ? actList[0].priceOut : actList[0].priceRoom;
            specInfo.showPrice = (specInfo.price / 100).toFixed(2);
            specInfo.title = actList[0].title;
            specInfo.packAmount = actList[0].goodsPackAmount;
            _this.setData({
                isLotSpec: 1,
                guigeShow: 1,
                chooseSpecInfo: specInfo,
                guigeList: actList,
                specGoodsPic: goodsInfo.goodsPic,
                guigecheck: specInfo.id,
            })
        } else {
            this.addQingdan(a);
        }
        if (!this.data.isOpen) {
            wx.showToast({
                title: '店铺休息中...',
                icon: 'none',
                duration: 1000 * 60 * 60 * 24
            })
            this.setData({
                manjiancheck: '店铺休息中...',
                shopSendMinprice: '休息中...',
                shopingenagh: 0,
            })
        }
        console.log(this.data.chooseSpecInfo);














        return;


        //////////////////////////下面是原始的//////////////////////
        let packPrice = '';
        this.changeGoodsNum(a.currentTarget.dataset.id, 1, a);
        this.computedPrice();
        this.data.addwupin.forEach(function(obj, index) {
            packPrice += parseFloat(obj.goodsPackAmount) * obj.goodsNum
        });
        this.setData({
            goodsmanjianall: this.data.goodsmanjianall,
            goodsmanjian: this.data.goodsmanjian,
            goodsPriceDisall: this.data.goodsPriceDisall,
            goodsPriceDisyuan: this.data.goodsPriceDisyuan,
            goodsmoney: this.data.goodsmoney,
            activityids1: this.data.activityids1,
            activityids2: this.data.activityids2,
            activityids3: this.data.activityids3,
            activityids4: this.data.activityids4,
            activityids5: this.data.activityids5,
            addwupin: this.data.addwupin,
            shopNum: this.data.shopNum,
            // goodsNum:this.data.goodsNum,
            yuanmoney: this.data.goodsmanjianall,
            moneybian: this.data.goodsmanjianall,
            money: this.data.goodsmanjianall,
            shopingCartPackPrice: packPrice,
            shopingenagh: this.data.goodsmanjianall * 1 >= this.trans(this.data.shopInfo.shopSendMinprice) ? 1 : 0,
            packPrice: packPrice

        });
    },
    // 减少商品
    reduce: function(a) {
        console.log(a);

        var goodsInfo = a.currentTarget.dataset.all; //当前菜品对象
        console.log(goodsInfo);
        //取出当前清单中的所有菜品列表
        var goodsList = this.data.chooseGoodsList;
        console.log(goodsList);
        var qGoodsInfo = goodsList[goodsInfo.id];
        if (!qGoodsInfo) {
            return;
        }

        console.log(qGoodsInfo);
        //判断当前选择的数量是否等于起售数量如果等于起售数量,则直接减去起售数量,
        //debugger;//this.data.isOut == 1 && 
        if (qGoodsInfo.goodsStartAt != 0 && qGoodsInfo.cnum == qGoodsInfo.goodsStartAt) {
            //移除改清单对象
            delete goodsList[goodsInfo.id];
            this.setData({
                guigecheck: 0,
                chooseGoodsList: goodsList,
                activityids: ''
            })
        } else {
            //-1
            qGoodsInfo.cnum--;
            if (qGoodsInfo.cnum == 0) { //为0的时候隐藏 - 按钮
                delete goodsList[goodsInfo.id];
                this.setData({
                    guigecheck: 0,
                    chooseGoodsList: goodsList,
                    activityids: ''
                })
            } else {
                goodsList[qGoodsInfo.id] = qGoodsInfo;
                this.setData({
                    chooseGoodsList: goodsList,
                    activityids: ''
                })
            }
        }

        //开始计算处理优惠
        this.youhui();
        var pri = this.data.myTotalPrice;
        console.log('目前总价:' + pri);
        console.log('目前总价:' + this.data.goodsmoney);

        if ((this.data.goodsmoney * 100) <= 0) {
            this.setData({
                showShopingCarts: 0,
                shopingenagh: 0,
            })
        }

        if (!this.data.isOpen) {
            wx.showToast({
                title: '店铺休息中...',
                icon: 'none',
                duration: 1000 * 60 * 60 * 24
            })
            this.setData({
                manjiancheck: '店铺休息中...',
                shopSendMinprice: '休息中...',
                shopingenagh: 0,
            })
        }
        console.log(this.data.chooseGoodsList);



















        return;
        let packPrice = '';
        this.changeGoodsNum(a.currentTarget.dataset.id, -1, a);
        this.computedPrice();
        this.data.addwupin.forEach(function(obj, index) {
            packPrice = parseFloat(obj.goodsPackAmount) * obj.goodsNum
        });
        this.setData({
            goodsmanjianall: this.data.goodsmanjianall,
            goodsmanjian: this.data.goodsmanjian,
            goodsPriceDisall: this.data.goodsPriceDisall,
            goodsPriceDisyuan: this.data.goodsPriceDisyuan,
            goodsmoney: this.data.goodsmoney,
            activityids1: this.data.activityids1,
            activityids2: this.data.activityids2,
            activityids3: this.data.activityids3,
            activityids4: this.data.activityids4,
            activityids5: this.data.activityids5,
            addwupin: this.data.addwupin,
            shopNum: this.data.shopNum,
            yuanmoney: this.data.goodsmanjianall,
            moneybian: this.data.goodsmanjianall,
            money: this.data.goodsmanjianall,
            shopingCartPackPrice: packPrice,
            shopingenagh: this.data.goodsmanjianall * 1 >= this.trans(this.data.shopInfo.shopSendMinprice) ? 1 : 0

        });
    },
    // 点击浮现弹窗
    showShopingCart: function() {
        console.log(1);
        if (this.data.showShopingCarts == 0) { //当前地球状态 0隐藏 1开启
            var tt = this.data.chooseGoodsList;
            if (JSON.stringify(tt) === '{}') {
                this.setData({
                    chooseGoodsList: null
                })
            }
            console.log(this.data.chooseGoodsList);
            if (!this.data.chooseGoodsList) {
                this.setData({
                    showShopingCarts: 0,
                    shopingType: 0,
                })
            } else {
                this.setData({
                    showShopingCarts: 1,
                    shopingType: 1,
                    shopingCartPackPrice: (this.data.packAmount / 100).toFixed(2),
                })
            }
        } else {
            if (!this.data.chooseGoodsList) {
                this.setData({
                    showShopingCarts: 0,
                    shopingType: 0,
                })
            } else {
                this.setData({
                    showShopingCarts: 0,
                    shopingType: 1,
                    shopingCartPackPrice: (this.data.packAmount / 100).toFixed(2),
                })
            }
        }
    },
    // 清除购物清单
    clearsShopingCart: function() {
        //改变地球状态
        //清空数量
        this.setData({
            chooseGoodsList: null,
            shopNum: 0,
            shopingType: 0,
            shopingenagh: 0,
            goodsSupport: this.data.isOut == 1 ? 1 : 2,
            shopSendMinprice: (this.data.shopInfo.shopSendMinprice / 100) + '元起送',
            showShopingCarts: 0,
            manjiancheck: this.data.manjians,
            activityids: '',
            xinKPrice: 0,
        })
        var k = 'orderInfo-' + (this.data.shopId ? this.data.shopId : this.data.shopInfo.id) + '-' + this.data.isOut;
        console.log(k);
        wx.removeStorage({
            key: k,
            success(res) {
                console.log(res);
                console.log(res.data)
            }
        })
    },
    // 分转元
    trans: function(a) {
        if (a) {
            return (parseFloat(a) / 100).toFixed(2);
        }
    },
    tranman: function(a) {
        if (a) {
            return (parseFloat(a) / 100);
        }
    },
    manjian: function(value) {
        let that = this;
        let arr = value.split(',')
        let meng = [],
            mengs = '';
        arr.forEach(function(obj, index) {
            obj.split('-').forEach(function(item, ind) {
                meng.push(item);
            })
        })

        meng.forEach(function(obj, index) {
            if (index % 2 == 0) {
                mengs += '满' + that.tranman(obj ? obj : '') + '元减'
            } else {
                mengs += that.tranman(obj ? obj : '') + '元,'
            }
        })
        mengs = mengs.substring(0, mengs.length - 1);
        return mengs.split(',')
    },
    manjianPd: function(value, type) {
        let that = this;
        let arr = value.split(',')
        let meng = [],
            mengs = [];
        arr.forEach(function(obj, index) {
            obj.split('-').forEach(function(item, ind) {
                meng.push(that.tranman(item));
            })
        })

        meng.forEach(function(obj, index) {
            if (type == 1) {
                if (index % 2 == 0) {
                    mengs.push(obj);
                }
            } else {
                if (index % 2 != 0) {
                    mengs.push(obj);
                }
            }

        })
        return mengs
    },
    details: function(a) {
        let dd = a.currentTarget.dataset.all;
        console.log(dd);
        let price = this.data.goodsSupport == 1 ? a.currentTarget.dataset.all.specList[0].priceOut : a.currentTarget.dataset.all.specList[0].priceRoom;
        console.log(dd.goodsDetail);
        dd.specList[0].price = price;
        dd.specList[0].num = 1;
        dd.goodsNum = 1;
        // console.log(dd);
        var picarr = [];
        picarr.push(dd.goodsPic);
        if (dd.goodsPicArr.includes(",")) {
            var arp = dd.goodsPicArr.split(',');
            for (var i = 0; i < arp.length; i++) {
                if (arp[i]) {
                    picarr.push(arp[i]);
                }
            }
        } else {
            picarr.push(dd.goodsPicArr);
        }
        this.setData({
            pinpaiDetailShow: 1,
            alertShow: 1,
            // shopId: a.currentTarget.dataset.id,
            detailed: dd,
            goodsPicArr: picarr

        })
        WxParse.wxParse('goodsDetailmg', 'html', this.data.detailed.goodsDetail, this, 0);
        console.log(this.data.goodsDetails);
        // console.log(a.currentTarget.dataset.all);
    },
    // 结算
    jiesuan: function() {
        if (!this.data.isOpen && this.data.isOut == 1) {
            wx.showToast({
                title: '店铺休息中...',
                icon: 'none',
                duration: 1000 * 60 * 60 * 24,
            })
            return;
        }
        var d = this.data;
        var _this = this;
        console.log(d);
        var act = d.activityids;
        var packa = d.packAmount;
        // console.log(mos);
        wx.setStorageSync('orderInfo-' + this.data.shopId + '-' + this.data.isOut, {
            shopId: this.data.shopId,
            shopTitle: d.shopInfo.shopTitle,
            totalPrice: d.myTotalPrice,
            packPrice: packa,
            activityids: act,
            goodsList: d.chooseGoodsList
        });
        var ppp = wx.getStorageSync('people');
        console.log(ppp);
        console.log(this.data.manyPeople);
        if (!wx.getStorageSync('people')) {
            this.setData({
                manyPeople: wx.getStorageSync('people').split('-')[0]
            });
        }
        if (this.data.goodsSupport == 2) {
            $.reqPost('xshop/getShopSetBySID', {
                shopId: d.shopId,
            }, function(res) {
                if (res.resultCode == 1000) {
                    if (res.returnObject.tablewareFee == 1) {

                        _this.setData({
                            peoplenum: 1,
                            tablewarePrice: res.returnObject.tablewarePrice
                        });
                    } else {
                        //清除桌台缓存
                        wx.removeStorageSync('people');
                        wx.navigateTo({
                            url: '../order/payOrder/payOrder?shopId=' + d.shopId,
                        })
                    }
                }
            })
        } else {
            wx.navigateTo({
                url: '../order/payOrder/payOrder?shopId=' + d.shopInfo.id,
            })
        }



        return;
        let that = this,
            activityids = '',
            packPrice = 0,
            mos = '';
        this.data.addwupin.forEach(function(obj, index) {
            // console.log(obj);
            obj.packPrice = parseFloat(obj.goodsPackAmount) * obj.goodsNum;
            obj.specList[0].num = obj.goodsNum;
        });
        // console.log(that.data.activityids1, that.data.activityids2, that.data.activityids3)
        activityids = that.data.activityids1 + that.data.activityids2 + that.data.activityids3 + that.data.activityids4 + that.data.activityids5
        activityids = activityids.substring(0, activityids.length - 1)
        if (that.data.activityids1) {
            mos = ((parseFloat(that.data.goodsmanjian) - (parseFloat(that.data.activityids1.split('-')[1] / 100) + parseFloat(packPrice)) / 100) * 100).toFixed(2)
        } else {
            mos = ((parseFloat(that.data.goodsmanjian) + parseFloat(packPrice) / 100) * 100).toFixed(2)
        }
        if (that.data.activityids3) {
            mos = ((parseFloat(that.data.goodsPriceDisall) + parseFloat(packPrice) / 100) * 100).toFixed(2)
        }
        // console.log(mos);
        wx.setStorageSync('orderInfo-' + that.data.shopInfo.id + '-' + this.data.isOut, {
            shopId: that.data.shopInfo.id,
            shopTitle: that.data.shopInfo.shopTitle,
            totalPrice: (this.data.goodsmoney * 100).toFixed(0),
            packPrice: packPrice,
            sendPrice: parseFloat(that.data.shopInfo.shopSendPrice),
            activityids: activityids,
            goodsList: that.data.addwupin
        });
        if (this.data.goodsSupport == 2) {
            $.reqPost('xshop/getShopSetBySID', {
                shopId: that.data.shopId,
            }, function(res) {
                if (res.resultCode == 1000) {
                    if (res.returnObject.tablewareFee == 1) {
                        that.setData({
                            peoplenum: 1,
                            tablewarePrice: res.returnObject.tablewarePrice
                        });
                    } else {
                        wx.navigateTo({
                            url: '../order/payOrder/payOrder?shopId=' + that.data.shopId,
                        })
                    }
                }
            })
        } else {
            wx.navigateTo({
                url: '../order/payOrder/payOrder?shopId=' + that.data.shopInfo.id,
            })
        }
    },

    closed: function(a) {
        if (a.currentTarget.dataset.type == 1) {
            this.setData({
                pinpaiDetailShow: 0,
                alertShow: 0
            })
        } else {
            this.setData({
                guigeShow: 0,
                youhuiShow: 0,
                alertShow: 0,
                peoplenum: 0
            })
        }
    },
    playphone: function(e) {
        wx.makePhoneCall({
            phoneNumber: this.data.shopInfo.userContact, //此号码并非真实电话号码，仅用于测试
            // phoneNumber: '15727393718',
            success: function() {
                // console.log("拨打电话成功！")
            },
            fail: function() {
                // console.log("拨打电话失败！")
            }
        });
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },

    /**
     * 改变商品数量
     */
    changeGoodsNum(id, num, a) {
        //当前点击上数据
        let obis = {},
            arr = [],
            // meng = 0,
            that = this,
            money = 0,
            packPrice = 0,
            shopNum = 0,
            goodsNum = 0;
        //当前
        this.data.checkalls.push(id);

        this.setData({
            checkalls: this.data.checkalls,
            shopingType: 1,
        });
        let goodsStartAt = a.currentTarget.dataset.all.goodsStartAt;
        let goodsLimitBuy = a.currentTarget.dataset.all.goodsLimitBuy ? a.currentTarget.dataset.all.goodsLimitBuy : 10000;
        // this.data.checkalls.forEach(function(obj, index) {
        //   if (obj == id) {
        //     meng += 1
        //   }
        // });

        //

        let isHava = false;

        //修改商品数量
        this.data.addwupin.forEach(function(obj, index) {
            if (obj.id == id) {
                if (obj.goodsNum >= goodsLimitBuy) {
                    obj.goodsNum = num > 0 ? goodsLimitBuy : obj.goodsNum + num;
                    if (obj.goodsNum == 5) {
                        wx.showToast({
                            title: '每单限购' + goodsLimitBuy + '件',
                            icon: 'none',
                            duration: 2000
                        });
                    }
                } else if (obj.goodsNum < goodsStartAt) {
                    obj.goodsNum += goodsStartAt * num;
                } else if (obj.goodsNum == goodsStartAt) {
                    if (num > 0) {
                        obj.goodsNum += num;
                    } else {
                        obj.goodsNum = 0;
                    }
                } else {
                    obj.goodsNum += num;
                }
                obj.specList[0].num = obj.goodsNum;
                isHava = true;
                // obj.specList.forEach(function(o, id) {
                //   if (o.id == currSpec) {
                //     o.num += 1;
                //   }
                // })
            }
        });


        if (!isHava) {
            obis.id = a.currentTarget.dataset.id;
            obis.goodsPriceDis = a.currentTarget.dataset.all.goodsPriceDis;
            obis.goodsPriceDisAdd = a.currentTarget.dataset.all.goodsPriceDisAdd;
            obis.goodsPriceDisNum = a.currentTarget.dataset.all.goodsPriceDisNum;
            obis.type = a.currentTarget.dataset.all.goodsSupport; //外卖或堂食
            obis.goodsPic = a.currentTarget.dataset.all.goodsPic; //菜品图片
            obis.goodsPicArr = a.currentTarget.dataset.all.goodsPicArr; //菜品图片
            obis.goodsTitle = a.currentTarget.dataset.all.goodsTitle; //菜品标题
            obis.goodsPackAmount = a.currentTarget.dataset.all.specList[0].goodsPackAmount; //包装费
            obis.specList = [];
            obis.goodsNum = a.currentTarget.dataset.all.goodsStartAt ? a.currentTarget.dataset.all.goodsStartAt : 1;
            obis.goodsStartAt = a.currentTarget.dataset.all.goodsStartAt;
            obis.goodsLimitBuy = a.currentTarget.dataset.all.goodsLimitBuy;
            this.data.addwupin.push(obis);
        }
        this.setData({
            addwupin: this.data.addwupin,
            goodsPicArr: obis.goodsPicArr
        })

        // 便利规格展示,順便处理商品数量为0的
        let currSpec = a.currentTarget.dataset.spec;
        let goodsArray = []
        for (let i = 0; i < this.data.addwupin.length; i++) {
            let goods = this.data.addwupin[i];
            if (goods.goodsNum > 0) {
                if (goods.id == id) {
                    // 有无当前规格
                    let isSpec = false;
                    let oldSpec = {};
                    for (let j = 0; j < goods.specList.length; j++) {
                        if (currSpec == goods.specList[j].specId) {
                            isSpec = true;
                            oldSpec = goods.specList[j];
                            break;
                        }
                    }

                    a.currentTarget.dataset.datas.forEach(function(obj, index) {
                        if (obj.id == currSpec) {
                            if (isSpec) {
                                oldSpec.num += num;
                                if (oldSpec.num <= 0) {
                                    // delete oldSpec;
                                } else
                                    oldSpec.totalPrice = (that.data.goodsSupport == 1 ? obj.priceOut : obj.priceRoom) * oldSpec.num;
                            } else {
                                goods.specList.push({
                                    title: obj.title,
                                    num: 1,
                                    price: that.data.goodsSupport == 1 ? obj.priceOut : obj.priceRoom,
                                    totalPrice: (that.data.goodsSupport == 1 ? obj.priceOut : obj.priceRoom) * 1,
                                    specId: obj.id
                                });
                            }
                        }
                    });
                }
                goodsArray.push(goods);
            }
        };


        this.setData({
            addwupin: goodsArray
        })
        if (goodsArray.length <= 0) {
            this.setData({
                shopNum: 0,
                shopingType: 0
            });
            return;
        }

        this.data.addwupin.forEach(function(obj, index) {
            if (shopNum >= goodsLimitBuy) return;
            if (obj.goodsNum < goodsStartAt) {
                shopNum += goodsStartAt;
            } else {

                shopNum += obj.goodsNum;
            }

        });

        this.setData({
            shopNum: shopNum
        })


        // this.data.addwupin.forEach(function(obj, index) {
        //   obj.specList.forEach(function(o, i) {
        //     money += o.totalPrice;
        //     shopNum += o.num;
        //   })
        // })
    },

    computedPrice() {
        let that = this;
        let isWaimai = this.data.goodsSupport == 1; //==1是外卖
        // console.log(that.data.addwupin)
        if (that.data.addwupin.length <= 0) {
            this.setData({
                goodsmoney: 0,
                manjiancheck: ""
            });
            return;
        }

        if (this.data.shopInfo.isNewUser == 'y') {
            this.data.activityids1 = '1-' + (act.k1 * 100).toFixed(0) + ','
        }

        if (isWaimai) {
            // 判斷是否有折扣
            let isZhekou = false;
            // console.log(that.data.addwupin)
            for (let i = 0; i < that.data.addwupin.length; i++) {
                let goods = that.data.addwupin[i];
                if (goods.goodsPriceDis) {
                    isZhekou = true;
                    break;
                }
            }
            let goodsmoneys = 0,
                goodsmoneysall = 0; //商品总价
            this.data.addwupin.forEach(function(goods, index) {
                // if(goods.goodsNum >= goods.goodsLimitBuy){
                //   return;
                // } else if (goods.goodsNum < goods.goodsStartAt){
                //   goods.goodsNum += goods.goodsStartAt;
                // }else{

                // }
                if (isZhekou) {
                    //有折扣
                    if (goods.goodsPriceDis) {
                        // 折扣
                        if (goods.goodsPriceDisNum >= goods.goodsNum) {
                            goodsmoneys += parseFloat(goods.goodsPriceDis) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum;
                            goodsmoneysall += parseFloat(goods.specList[0].price / 100) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum
                        } else {
                            goodsmoneys += parseFloat(goods.goodsPriceDis) * goods.goodsPriceDisNum;
                            goodsmoneys += parseFloat(goods.specList[0].price / 100) * (goods.goodsNum - goods.goodsPriceDisNum) + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum;
                            goodsmoneysall += parseFloat(goods.specList[0].price / 100) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum
                        }
                    } else { //非折扣，用原价
                        goodsmoneys += parseFloat(goods.specList[0].price / 100) * goods.specList[0].num + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum;
                        goodsmoneysall += parseFloat(goods.specList[0].price / 100) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum
                    }
                    that.data.activityids2 = '3-' + ((goodsmoneysall - goodsmoneys) * 100).toFixed(0) + ','
                } else {
                    // 非折扣即满减
                    goodsmoneys += (goods.specList[0].price / 100) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum;
                    goodsmoneysall += (goods.specList[0].price / 100) * goods.goodsNum + parseFloat(goods.goodsPackAmount / 100) * goods.goodsNum;
                }
            });
            if (!isZhekou) {
                that.setData({
                    goodsmanjianall: goodsmoneys,
                    // goodsmoney: goodsmoneys
                    // moneyAll: goodsmoneysall
                });
                that.doManjian(0, isWaimai);
            } else {
                that.setData({
                    goodsmoney: goodsmoneys,
                    goodsmanjianall: goodsmoneysall
                    // moneyAll:  goodsmoneysall
                });
            }
            // debugger

        } else { //堂
            let zhekeMoney = 0; //总价
            let manjianMoney = 0; //满减商品
            let k4 = that.data.act.k4;
            this.data.addwupin.forEach(function(goods, i) {
                // //总价
                // if (!k4) {
                //   // 折扣
                //   if (goods.goodsPriceDisNum >= goods.goodsNum) {
                //     zhekeMoney += parseFloat(goods.goodsPriceDis) * goods.goodsNum;
                //   } else {
                //     zhekeMoney += parseFloat(goodsPriceDis) * goods.goodsPriceDisNum;
                //     zhekeMoney += (goods.specList[0].price / 100) * (goods.goodsNum - goods.goodsPriceDisNum);
                //   }
                // } else {
                //   // 非折扣即满减
                //   manjianMoney += (goods.specList[0].price / 100) * goods.goodsNum;
                // }
                manjianMoney += (goods.specList[0].price / 100) * goods.goodsNum;
            });

            this.setData({
                goodsmanjianall: manjianMoney,
                // moneyAll: manjianMoney
            });
            this.doManjian(0, isWaimai)
        }

    },
    /**
     * 处理满减
     */

    doManjian: function(zhekeMoney, isWaimai) {
        if (this.data.goodsmanjianall <= 0) return;
        let that = this;
        let manjian = 0;
        let manjiancheck = "";
        if (this.data.manjianPanduan.length > 0) {
            for (let i = 0; i < that.data.manjianPanduan.length; i++) {
                if (that.data.goodsmanjianall >= that.data.manjianPanduan[i]) {
                    if (parseFloat(that.data.manjianPanduan[i + 1])) {
                        manjian = (parseFloat(that.data.goodsmanjianall) - parseFloat(that.data.manjianz[i])).toFixed(2)
                        manjiancheck = '已减' + parseFloat(that.data.manjianz[i]) + '元，再买' + (that.data.manjianPanduan[i + 1] - that.data.goodsmanjianall) + '元减' + that.data.manjianz[i + 1]

                    } else {
                        manjian = (parseFloat(that.data.goodsmanjianall) - parseFloat(that.data.manjianz[i])).toFixed(2)
                        manjiancheck = '已减' + parseFloat(that.data.manjianz[i]) + '元';
                    }
                    // console.log(that.data.money, that.data.moneybian, that.data.activityids2)
                } else {
                    // console.log(that.data.shopSendMinprice);
                    if (that.data.goodsmanjianall < that.data.shopSendMinprice) {
                        manjiancheck = '还差' + (that.data.shopSendMinprice - that.data.goodsmanjianall).toFixed(2) + '元起送';
                        manjian = that.data.goodsmanjianall;
                    } else {
                        if (i === 0) {
                            manjiancheck = that.data.manjians[i] + ',再买' + (that.data.manjianPanduan[i] - that.data.goodsmanjianall).toFixed(2) + '减' + that.data.manjianz[i] + '元';
                        }
                    };
                    break;
                }
            };
        } else {
            manjian = this.data.goodsmanjianall;
            if (isWaimai) {
                if (manjian < this.data.shopSendMinprice) {
                    manjiancheck = '还差' + (that.data.shopSendMinprice - that.data.goodsmanjianall).toFixed(2) + '元起送';
                    that.setData({
                        goodsmoney: manjian
                    });
                }
            }
        }



        let sumMoney = manjian + zhekeMoney;
        if (!isWaimai) {
            // 堂食
            if (that.data.act.k5) {
                // 折扣
                sumMoney = sumMoney * (parseFloat(act.k5) / 100)
            }
        }


        sumMoney = new Number(sumMoney).toFixed(2)

        if (isWaimai) {
            if (that.data.act.k1) {
                this.data.activityids2 = '1-' + (parseFloat(act.k1) * 100).toFixed(0) + ','
            }
            if (that.data.act.k2)
                this.data.activityids2 = '2-' + ((this.data.goodsmanjianall - sumMoney) * 100).toFixed(0) + ','
        } else {
            if (that.data.act.k4)
                this.data.activityids4 = '4-' + ((this.data.goodsmanjianall - sumMoney).toFixed(2) * 100).toFixed(0) + ','
            if (that.data.act.k5) {
                this.data.activityids5 = '5-' + ((sumMoney * (1 - parseFloat(that.data.act.k5) / 100).toFixed(2))).toFixed(0) * 100 + ',';
            }
        }
        // console.log(this.data.activityids2, this.data.activityids3, this.data.activityids4, this.data.activityids5)
        that.setData({
            goodsmoney: sumMoney,
            manjiancheck: manjiancheck,
            // moneyAll: sumMoney
        });
        // console.log(this.data.goodsmoney)
    },
    closegoumaialert: function() {
        this.setData({
            showShopingCarts: 0
        })
    },
    closeyouhui: function() {
        this.setData({
            youhuiShow: 0,
            alertShow: 0
        })
    }
})